<extend name="Base:main" />
<block name="title">
<title>蔬菜外卖 - 用户管理</title>
</block>
<block name="main-content">
<div class="row">
	<div class="box col-md-12">
		<div class="box-inner">
			<div class="box-header well" data-original-title="">
				<h2>
					<i class="glyphicon glyphicon-user"></i>用户管理
				</h2>

				<div class="box-icon">
					<a href="#" class="btn btn-add btn-round btn-default"><i
						class="glyphicon glyphicon-plus"></i></a> <a href="#"
						class="btn btn-minimize btn-round btn-default"><i
						class="glyphicon glyphicon-chevron-up"></i></a> <a href="#"
						class="btn btn-close btn-round btn-default"><i
						class="glyphicon glyphicon-remove"></i></a>
				</div>
			</div>
			<div class="box-content">
				<div class="alert alert-info">对用户进行查看以及管理</div>
				<div class="loading col-sm-12 center">
					<img src="__PUBLIC__/img/ajax-loaders/ajax-loader-5.gif">
				</div>
				<table
					class="table table-striped table-bordered bootstrap-datatable datatable responsive"
					id="orderlist" style="display: none;">
					<thead>
						<tr>
							<th>序号</th>
							<th>名字</th>
							<th>账号</th>
							<th>权限</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<foreach name="list" item="v">
						<tr id="row_{$v.id}">
							<td><if condition="($_GET['p'] eq 0)">{++$i}<else />{++$i
								+ ($_GET['p']-1) * 20}</if></td>
							<td>{$v.name}</td>
							<td>{$v.account}</td>
							<th><if condition="($v.status eq 1)"> <span
									class="label-success label label-default">管理员</span> <else />
								<span class="label-warning label label-default">职员</span> </if></th>
							<td>
								<button class="btn btn-primary btn-xs"
									onclick="javascript:showOrder('{$v.name}');">
									<i class="glyphicon glyphicon-search icon-white"></i>
								</button>
								<button class="btn btn-primary btn-xs"
									onclick="edit('{$v.id}');">
									<i class="glyphicon glyphicon-edit icon-white"></i>
								</button> <if condition="($v.status neq 1)">
								<button class="btn btn-danger btn-xs btn-delete" id="{$v.id}">
									<i class="glyphicon glyphicon-trash icon-white"></i>
								</button>
								</if>
							</td>
						</tr>
						</foreach>
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<!--/span-->
	<div id="staff_content"></div>
</div>
<!--/row--> <!-- end row --> <!-- 删除菜单弹出框 -->
<div class="modal fade" id="myDeleteModal" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">删除</h4>
			</div>
			<div class="modal-body">
				<p id="sccontent" name="sccontent" style="font-size: 15px">你确定要删除该职员吗？该操作不可恢复！</p>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				<button type="button" class="btn btn-danger">确定</button>
			</div>
		</div>
	</div>
</div>
<!-- 添加菜单弹出框 -->
<div class="modal fade" id="myAddModal" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width: 900px;">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">添加</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal style-form" id="form_add"
					action="__APP__/Admin/Staff/addStaff" method="post"
					enctype="multipart/form-data">
					<div class="form-group">
						<label class="col-sm-2 control-label">账号：</label>
						<div class="col-sm-9 ">
							<input type="text" name="account" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">姓名：</label>
						<div class="col-sm-9 ">
							<input type="text" name="name" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">密码：</label>
						<div class="col-sm-9 ">
							<input type="text" name="password" class="form-control">
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				<button type="button" class="btn btn-danger">确定</button>
			</div>
		</div>
	</div>
</div>
<!-- 修改菜单弹出框 -->
<div class="modal fade" id="myEditModal" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width: 900px;">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">修改</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal style-form" id="form_update"
					action="__APP__/Admin/Staff/update" method="post"
					enctype="multipart/form-data">
					<input type="hidden" id="id" name="id" class="form-control">
					<div class="form-group">
						<label class="col-sm-2 control-label">账号：</label>
						<div class="col-sm-9 ">
							<input type="text" id="account" name="account"
								class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">姓名：</label>
						<div class="col-sm-9 ">
							<input type="text" id="name" name="name" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">密码：</label>
						<div class="col-sm-9 ">
							<input type="text" name="password" placeholder="若不修改则不用填写"
								class="form-control">
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				<button type="button" class="btn btn-danger">确定</button>
			</div>
		</div>
	</div>
</div>
</block>
<block name="js-content"> <script>
var deleteUrl="__APP__/Admin/System/deleteInfo";
var getInfo="__APP__/Admin/System/getInfo";

var showOrderUrl="__APP__/Admin/Staff/staffOrder";

var action = "Staff";
 //打开编辑的modal.
function  edit(id)
{
	$(".btn-danger").attr('id',id);
	$.post(getInfo,{id:id,action:action},function(data){
		if(data){
			$("#id").val(data['id']);
			$("#name").val(data['name']);
			$("#account").val(data['account']);
		}
	});
	$("#myEditModal").modal('show');
}
$('#myEditModal').on('click','button.btn-danger',function (a){
	$("#form_update").submit();
});
function showOrder(staff){
	$.post(showOrderUrl,{staff:staff},function(data){
		$('#staff_content').html(data);
	});
}
</script> </block>
